home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 1999 #5 / 1999 CD 5 (black).iso / Delphi3 / install / data.z / MEMOAUTO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-05  |  2.2 KB  |  81 lines

  1. unit MemoAuto;
  2.  
  3. { This unit implements TMemoApp, the Application automation object class for
  4.   the MemoEdit application. TMemoApp is registered as a Single Instance
  5.   automation class, thus causing a new copy of the application to be run each
  6.   time an OLE Automation controller asks for an instance of the "Memo.MemoApp"
  7.   OLE class name. TMemoApp implements the following automated methods and properties:
  8.  
  9.   function NewMemo: OleVariant;
  10.     Creates a new editor window and returns the window's automation object.
  11.  
  12.   function OpenMemo(const FileName: WideString): OleVariant;
  13.     Loads an existing file into a new editor window and returns the window's
  14.     automation object.
  15.  
  16.   procedure TileWindows;
  17.     Tiles all open editor windows.
  18.  
  19.   procedure CascadeWindows;
  20.     Cascades all open editor windows.
  21.  
  22.   property MemoCount: Integer;
  23.     Number of open editor windows.
  24.  
  25.   property Memos[Index: Integer]: OleVariant;
  26.     Array of automation objects for the currently open editor windows. }
  27.  
  28. interface
  29.  
  30. uses
  31.   ComObj, Memo_TLB;
  32.  
  33. type
  34.   TMemoApp = class(TAutoObject, IMemoApp)
  35.   protected
  36.     function Get_MemoCount: Integer; safecall;
  37.     function Get_Memos(Index: Integer): OleVariant; safecall;
  38.     function NewMemo: OleVariant; safecall;
  39.     function OpenMemo(const FileName: WideString): OleVariant; safecall;
  40.     procedure CascadeWindows; safecall;
  41.     procedure TileWindows; safecall;
  42.   end;
  43.  
  44. implementation
  45.  
  46. uses ComServ, MainFrm, EditFrm;
  47.  
  48. function TMemoApp.Get_MemoCount: Integer;
  49. begin
  50.   Result := MainForm.MDIChildCount;
  51. end;
  52.  
  53. function TMemoApp.Get_Memos(Index: Integer): OleVariant;
  54. begin
  55.   Result := TEditForm(MainForm.MDIChildren[Index]).OleObject;
  56. end;
  57.  
  58. function TMemoApp.NewMemo: OleVariant;
  59. begin
  60.   Result := MainForm.CreateMemo('').OleObject;
  61. end;
  62.  
  63. function TMemoApp.OpenMemo(const FileName: WideString): OleVariant;
  64. begin
  65.   Result := MainForm.CreateMemo(FileName).OleObject;
  66. end;
  67.  
  68. procedure TMemoApp.CascadeWindows;
  69. begin
  70.   MainForm.Cascade;
  71. end;
  72.  
  73. procedure TMemoApp.TileWindows;
  74. begin
  75.   MainForm.Tile;
  76. end;
  77.  
  78. initialization
  79.   TAutoObjectFactory.Create(ComServer, TMemoApp, Class_MemoApp, ciSingleInstance);
  80. end.
  81.